Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enforcement for deviceAccess #4913

Merged
merged 82 commits into from
Mar 17, 2020

Conversation

idettman
Copy link
Contributor

@idettman idettman commented Feb 28, 2020

Type of change

  • Does this change affect user-facing APIs or examples documented on http://prebid.org?

Description of change

Addresses: Issue #4747

We discussed in a Prebid.js meeting and came up with a radically simpler (and quicker) approach, relying on the publisher to determine when to turn off device access and then configure:

  1. turn off usersync (already supported with the syncEnabled flag)
  2. turn off userId modules (just don't configure them)
  3. turn off utils setCookie,getCookie,hasLocalStorage (new config option)
  4. review to ensure that all modules are either using the core utils functions or paying attention to a new config option.

The proposed new config option is:
pbjs.setConfig({ deviceAccess: false });

Acceptance Criteria

  • When the deviceAccess flag config option is set to false, no cookies are read or set
  • When the deviceAccess flag config option is set to true, cookies may be read and set
  • When the deviceAccess flag config option is not set, cookies may be read and set

nakamoto and others added 30 commits February 16, 2019 21:30
# Conflicts:
#	modules/advangelistsBidAdapter.js
#	test/spec/modules/advangelistsBidAdapter_spec.js
@idettman idettman force-pushed the add-enforcement-device-access branch 2 times, most recently from dbf8a53 to c3c5b09 Compare February 29, 2020 05:55
@pycnvr
Copy link
Collaborator

pycnvr commented Mar 3, 2020

Hi @idettman

It might be useful to add a bit more protection for pubCommonIdSystem. With deviceAccess == false, it still keeps generating new uuid as userId.pubcid even though they are not persisted.

In pubCommonIdSystem.js line 67, add a check to prevent id creation.

    const newId = (create && utils.hasDeviceAccess()) ? utils.generateUUID() : undefined;

@@ -83,8 +83,7 @@ function writeDigiId(id) {
var key = 'DigiTrust.v1.identity';
var date = new Date();
date.setTime(date.getTime() + 604800000);
var exp = 'expires=' + date.toUTCString();
document.cookie = key + '=' + encId(id) + '; ' + exp + '; path=/;SameSite=none;';
utils.setCookie(key, encId(id), date.toUTCString(), 'none');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may require more refactoring because encId(), calls encodeURIComponent() and so does setCookie(). encoding twice could be a problem if it's not decoded twice on the other end. So maybe we refactor encId() or maybe add an option to setCookie() to NOT encode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me look into this. The id is typically passed through and decoded via a server-side process. I'll see if there is a reasonable place to account for possible double encoding in that pipeline.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goosemanjack - would like to get this ticket merged. Should we remove the call to encId()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a change here. Removed the call to encodeURI from encId. @goosemanjack - please review when you get a chance, but we need to merge this PR.

@@ -23,7 +23,7 @@ pV6EP3MTLosuUEpLaQIDAQAB
export function getAdagioScript() {
try {
const w = utils.getWindowTop();
const ls = w.localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY);
const ls = (utils.hasLocalStorage()) ? w.localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY) : null;
Copy link
Collaborator

@osazos osazos Mar 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

As utils.getDataFromLocalStorage() checks if localStorage is available and returns null if nothing is found, we can just use:

const ls = utils.getDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);

Also, we call localStorage twice later in our bidder : lines 37 and 51. For this lines, we should use:

utils.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);

Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osazos - you can go ahead and make the change you've suggested.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bretg, I created #4978.
Honestly, I don't know if there is a better way to submit my change. Please fell free to tell me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osazos - I merged your changes from #4978 -- will close that PR.

@bretg bretg requested a review from jsnellbaker March 12, 2020 14:48
@@ -342,15 +342,15 @@ function getLanguage() {

function getLocalStorageSafely(key) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @bretg!
I'm ok with the changes
However if utils.getDataFromLocalStorage(key) makes all safety checks, try/catch here could be avoided. Same in setLocalStorageSafely

bretg added 2 commits March 17, 2020 10:21
We need to get moving on this merge, so I made an update -- the encId() function appears to be necessary to stringify and btoa() the ID. Just removed the layer of URL encoding in that function as duplicate of what happens in the PBJS setCookie fn.
@bretg
Copy link
Collaborator

bretg commented Mar 17, 2020

Thanks for the reviews. Merging to get into today's release.

@bretg bretg merged commit a95f911 into prebid:master Mar 17, 2020
@bretg bretg removed needs 2nd review Core module updates require two approvals from the core team needs review labels Mar 17, 2020
bmwcmw pushed a commit to criteo-forks/Prebid.js that referenced this pull request Mar 31, 2020
* Add microadBidAdapter

* Remove unnecessary encodeURIComponent from microadBidAdapter

* Submit Advangelists Prebid Adapter

* Submit Advangelists Prebid Adapter 1.1

* Correct procudtion endpoint for prebid

* analytics update with wrapper name

* reverted error merge

* update changed default value of netRevenue to true

* Re-add rubicon analytics without deprecated getTopWindowUrl util

* Cache referrer on auction_init instead of bid_requested

* add config for deviceAccess enforcement in utils getCookie setCookie and hasLocalStorage

* add tests, and updates to names/comments

* add deviceAccess enforcement to util method cookiesAreEnabled

* update to adspendBidAdapter for device access enforcement

* update to pubCommonId for device access enforcement

* update widespaceBidAdapter for device access enforcement. updated utils storage methods with jsdoc typing, hasLocalStorage changed to only return boolean type

* update to digiTrustIdSystem for device access enforcement

* updated utils.setCookie signature, adding a 'domain' argument. update to invibesBidAdapter for device access enforcement

* updated utils to group similar storage methods

* updated kargoBidAdapter for add-enforcement-device-access

* update to minimize changes in adapters using browser storage

* updated modules with localStorage or cookie methods to use utils

* updated invibesBidAdapter use of storage methods to use utils

* fix for wrong obj reference for date string

* revert accidental change to package.json

* fix linting error, trailing comma. removed unnecessary cookie get set functions and replaced with util methods

* reverted change to removed extra methods since it breaks unit test

* fix for pubcommonidsystem id generation

* update jsdoc param 'domain'

* Update adagioBidAdapter.js

merging changes from prebid#4978

* Removing encoding in DT encId

We need to get moving on this merge, so I made an update -- the encId() function appears to be necessary to stringify and btoa() the ID. Just removed the layer of URL encoding in that function as duplicate of what happens in the PBJS setCookie fn.

Co-authored-by: nakamoto <nakamoto_tatsuya@microad.co.jp>
Co-authored-by: Chandra Prakash <chandra.prakash@advangelists.com>
Co-authored-by: Eric Harper <eharper@rubiconproject.com>
Co-authored-by: TJ Eastmond <teastmond@la-wlandaverde-mac.local>
Co-authored-by: Mark Monday <mmonday@rubiconproject.com>
Co-authored-by: msm0504 <51493331+msm0504@users.noreply.github.com>
Co-authored-by: bretg <bgorsline@gmail.com>
rjvelicaria pushed a commit to openx/Prebid.js that referenced this pull request Apr 9, 2020
* Add microadBidAdapter

* Remove unnecessary encodeURIComponent from microadBidAdapter

* Submit Advangelists Prebid Adapter

* Submit Advangelists Prebid Adapter 1.1

* Correct procudtion endpoint for prebid

* analytics update with wrapper name

* reverted error merge

* update changed default value of netRevenue to true

* Re-add rubicon analytics without deprecated getTopWindowUrl util

* Cache referrer on auction_init instead of bid_requested

* add config for deviceAccess enforcement in utils getCookie setCookie and hasLocalStorage

* add tests, and updates to names/comments

* add deviceAccess enforcement to util method cookiesAreEnabled

* update to adspendBidAdapter for device access enforcement

* update to pubCommonId for device access enforcement

* update widespaceBidAdapter for device access enforcement. updated utils storage methods with jsdoc typing, hasLocalStorage changed to only return boolean type

* update to digiTrustIdSystem for device access enforcement

* updated utils.setCookie signature, adding a 'domain' argument. update to invibesBidAdapter for device access enforcement

* updated utils to group similar storage methods

* updated kargoBidAdapter for add-enforcement-device-access

* update to minimize changes in adapters using browser storage

* updated modules with localStorage or cookie methods to use utils

* updated invibesBidAdapter use of storage methods to use utils

* fix for wrong obj reference for date string

* revert accidental change to package.json

* fix linting error, trailing comma. removed unnecessary cookie get set functions and replaced with util methods

* reverted change to removed extra methods since it breaks unit test

* fix for pubcommonidsystem id generation

* update jsdoc param 'domain'

* Update adagioBidAdapter.js

merging changes from prebid#4978

* Removing encoding in DT encId

We need to get moving on this merge, so I made an update -- the encId() function appears to be necessary to stringify and btoa() the ID. Just removed the layer of URL encoding in that function as duplicate of what happens in the PBJS setCookie fn.

Co-authored-by: nakamoto <nakamoto_tatsuya@microad.co.jp>
Co-authored-by: Chandra Prakash <chandra.prakash@advangelists.com>
Co-authored-by: Eric Harper <eharper@rubiconproject.com>
Co-authored-by: TJ Eastmond <teastmond@la-wlandaverde-mac.local>
Co-authored-by: Mark Monday <mmonday@rubiconproject.com>
Co-authored-by: msm0504 <51493331+msm0504@users.noreply.github.com>
Co-authored-by: bretg <bgorsline@gmail.com>
iggyfisk pushed a commit to happypancake/Prebid.js that referenced this pull request Jun 22, 2020
* Add microadBidAdapter

* Remove unnecessary encodeURIComponent from microadBidAdapter

* Submit Advangelists Prebid Adapter

* Submit Advangelists Prebid Adapter 1.1

* Correct procudtion endpoint for prebid

* analytics update with wrapper name

* reverted error merge

* update changed default value of netRevenue to true

* Re-add rubicon analytics without deprecated getTopWindowUrl util

* Cache referrer on auction_init instead of bid_requested

* add config for deviceAccess enforcement in utils getCookie setCookie and hasLocalStorage

* add tests, and updates to names/comments

* add deviceAccess enforcement to util method cookiesAreEnabled

* update to adspendBidAdapter for device access enforcement

* update to pubCommonId for device access enforcement

* update widespaceBidAdapter for device access enforcement. updated utils storage methods with jsdoc typing, hasLocalStorage changed to only return boolean type

* update to digiTrustIdSystem for device access enforcement

* updated utils.setCookie signature, adding a 'domain' argument. update to invibesBidAdapter for device access enforcement

* updated utils to group similar storage methods

* updated kargoBidAdapter for add-enforcement-device-access

* update to minimize changes in adapters using browser storage

* updated modules with localStorage or cookie methods to use utils

* updated invibesBidAdapter use of storage methods to use utils

* fix for wrong obj reference for date string

* revert accidental change to package.json

* fix linting error, trailing comma. removed unnecessary cookie get set functions and replaced with util methods

* reverted change to removed extra methods since it breaks unit test

* fix for pubcommonidsystem id generation

* update jsdoc param 'domain'

* Update adagioBidAdapter.js

merging changes from prebid#4978

* Removing encoding in DT encId

We need to get moving on this merge, so I made an update -- the encId() function appears to be necessary to stringify and btoa() the ID. Just removed the layer of URL encoding in that function as duplicate of what happens in the PBJS setCookie fn.

Co-authored-by: nakamoto <nakamoto_tatsuya@microad.co.jp>
Co-authored-by: Chandra Prakash <chandra.prakash@advangelists.com>
Co-authored-by: Eric Harper <eharper@rubiconproject.com>
Co-authored-by: TJ Eastmond <teastmond@la-wlandaverde-mac.local>
Co-authored-by: Mark Monday <mmonday@rubiconproject.com>
Co-authored-by: msm0504 <51493331+msm0504@users.noreply.github.com>
Co-authored-by: bretg <bgorsline@gmail.com>
@robertrmartinez robertrmartinez deleted the add-enforcement-device-access branch July 5, 2023 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal for Prebid.js Enforcement of Device Access
10 participants